<template>
    <el-container>
        <el-header :height="'auto'" class="mb20">
            <breadcrumb :title="'数据需求与问题反馈'" :noBack="true"></breadcrumb>
        </el-header>
        <el-main>
            <el-container class="white-block box full" v-loading="loading">
                <el-header :height="'auto'">
                    <div class="toolbar">
                        <div>
                            <el-input v-model="replyName" placeholder="请输入数据源名称" class="input mr10"
                                      size="small"></el-input>
                            <el-button class="primary" size="small" @click="getList()">查询</el-button>
                        </div>
                        <div class="text-right">
                            <el-button type="primary" class="primary" size="small" @click="goLink">新增</el-button>
                        </div>
                    </div>
                </el-header>
                <el-main class="mt10">
                    <table-example :data="tableData" :tableColumn="header" :slotColumns="slotColumns" :height="'100%'"
                                   ref="table">
                        <template slot="requirementType" slot-scope="scope">
                            <span v-if="scope.row.requirementType==1">数据需求</span>
                            <span v-if="scope.row.requirementType==2">问题反馈</span>
                        </template>
                        <template slot="requirementState" slot-scope="scope">
                            <span v-if="scope.row.requirementState==1">待回复</span>
                            <span v-if="scope.row.requirementState==2">已回复</span>
                        </template>
                        <template slot="operation" slot-scope="scope">
                            <el-link type="primary" :underline="false" @click="query(scope.row)">查看
                            </el-link>
                        </template>
                    </table-example>
                </el-main>
                <el-footer :height="'auto'" class="mt20">
                    <page :data="page" v-if="page" class="page" @jumpPage="getList"></page>
                </el-footer>
            </el-container>
            <transition name="slide">
                <router-view @upload="getList"></router-view>
            </transition>
        </el-main>
    </el-container>
</template>

<script>
    import breadcrumb from '../../components/breadcrumb'
    import tableExample from '../../components/table'
    import page from '../../components/pagination'

    export default {
        data() {
            return {
                replyName: '',
                tableData: [],
                header: [
                    {
                        prop: 'requirementName',
                        label: '需求名称',
                        minWidth: 130,
                        align: 'center',
                        headerAlign: 'center'
                    },
                    {
                        prop: 'requirementType',
                        label: '类型',
                        minWidth: 150,
                        align: 'center',
                        headerAlign: 'center'
                    },
                    {
                        prop: 'requirementState',
                        label: '状态',
                        minWidth: 120,
                        align: 'center',
                        headerAlign: 'center'
                    },
                    {
                        prop: 'applyTime',
                        label: '申请时间',
                        minWidth: 150,
                        align: 'center',
                        headerAlign: 'center'
                    },
                    {
                        prop: 'operation',
                        label: '操作',
                        align: 'center',
                        minWidth: 100,
                        fixed: 'right'
                    }
                ],
                slotColumns: ['operation', 'requirementType', 'requirementState'],
                page: null,
                loading: false,
                index: 1
            }
        },
        mounted() {
            this.getList()
        },
        methods: {
            getList(index) {
                this.loading = true
                if (index) this.index = index
                this.$http.get('/requirementReply/getRequirementList', {
                    requirementName: this.replyName || '',
                    requirementState: '',
                    requireOrReply: 1,
                    current: this.index || 1,
                    size: 15
                }).then(result => {
                    this.loading = false
                    if (result.success) {
                        this.tableData = result.data.records
                        this.page = result.data
                        delete this.page['records']
                    }
                })
            },
            goLink() {
                this.$router.push({
                    path: this.$route.path + '/add'
                })
            },
            query(row) {
                this.$router.push({
                    path: this.$route.path + '/detail',
                    query: {
                        id: row.id
                    }
                })
            }
        },
        components: {
            breadcrumb,
            tableExample,
            page
        }
    }
</script>

<style scoped lang="less">

</style>
